<?php
include('rootlogin.php');
//include('../incsession.php');
include("path.php");
session_start();
$level=2;
if(!isset($_FILES['video']['tmp_name'])){
			$flag=0;
}
else{
	//$uploaddir = 'E:/xampp/htdocs/1223/video/';
	$uploadfile = $uploaddir.basename($_FILES['video']['name']);

	if (move_uploaded_file($_FILES['video']['tmp_name'], $uploadfile)) {
		
		
		$vocab=$_FILES['video']['name'];
		if(false!= ($pos=strripos($vocab, '.'))){
			$vocab=substr($vocab, 0, $pos);
		}
		$query = "UPDATE video SET vname='".$_FILES['video']['name']."', vocab='".$vocab.$_SESSION['topicid']."_".$level.".txt'  
				WHERE topicid=".$_SESSION['topicid']." AND 
					level=".$level;
		$result = mysql_query($query,$user_con) or die('<font color="#C11B17">Error. Please go back to the previous page and try again.</font>');	
		//echo "<meta http-equiv=refresh content=\"0;url=video_intro1.php\">";
		header ("location: vocab2.php");
	} 
	else {
		$flag=1;
	}
	
}
?>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="framestyle.css" type="text/css" media="screen">
<div id="wrapper">
<div id="title">Online Listening Comprehension Program</div>

<div id="main">
<hr/>
<div id="title2">FOR INTERMEDIATE LEVEL: UPLOAD A VIDEO</div>
<div id="title3">1. The file name must consist of only English alphabets; both upper case and lower case are OK, e.g. StudyAbroad<br>
2. Characters such as _-'"+=@#... which are not English alphabets are not allowed and will stop the video from playing.<br>
3. The video format must be FLV, e.g. StudyAbroad.flv</div>
<hr/>
<br><br>
<?php
	if($flag==1){
		echo "<div id='error'>Error. Please upload the file again.</div><br>";
	}
?>
<form action="upload2.php" method="post" enctype="multipart/form-data">

<input type="file" name="video" size="60">

<input type="submit" name = "next" value = "upload">
</form>
</div>
</div>